﻿$(document).ready(function () {
    //添加导航
    $("#J_nav").addClass("nav-activity");

    //过期商品删除链接
    $("#J_product li[class!='ing']").find("a").removeAttr("href");
    //赢家滚动
    if ($("#J_winerlist li").length > 0) {
        $("#J_winerlist").find("p").animate({ opacity: 'hide', height: 0 }, 3000, function () {
            setInterval("slide($('#J_slide'),18,500)", 1500);
        });
    };
});

//轮播
function slide(element, step, time) {
    var slide_list = element.find(".slide-list");
    var slide_triggers = element.find(".slide-triggers");
    var count = slide_list.children().length;
    if ((count < 2) || (slide_list.height() < element.height() + step)) { return; }
    var slide_list_first = slide_list.children().eq(0);
    var eq = parseInt(element.attr("data-eq"));
    if (isNaN(eq)) { eq = -1; element.attr("data-eq", "0"); };
    eq += 1;
    if (eq > count - 1) {
        eq = 0;
        slide_list.animate({ top: -count * step }, time, function () {
            slide_list.animate({ top: 0 }, 0);
            slide_list.children().removeAttr("style");
        });
    } else {
        slide_list.animate({ top: -eq * step }, time);
    }
    if (slide_list.height() - count * step < element.height()) {
        for (var i = 0; i < eq - 1; i++) {
            slide_list.children().eq(i).css({ "position": "relative", "top": (count * step) + "px" });
        };
    };
    element.attr("data-eq", eq);
    slide_triggers.children().removeClass("slide-current").eq(eq).addClass("slide-current");
};